<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="Crear Direccion del Cliente"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form id="frm">
                <h:panelGrid columns="2">
                    <h:outputLabel value="" for="addressid" />
                    <h:inputHidden id="addressid" value="0"></h:inputHidden>
                    
                    <h:outputLabel value="Direccion" for="addressstreet" />
                    <h:inputText id="addressstreet" value="#{addressController.selected.addressstreet}" title="#{bundle.CreateAddressTitle_addressstreet}" required="true" requiredMessage="#{bundle.CreateAddressRequiredMessage_addressstreet}"/>
                    
                    <h:outputLabel value="Tipo" for="addresstype" />
                    <h:inputText id="addresstype" value="#{addressController.selected.addresstype}" title="#{bundle.CreateAddressTitle_addresstype}" required="true" requiredMessage="#{bundle.CreateAddressRequiredMessage_addresstype}"/>
                    
                    <h:outputLabel value="Barrio" for="addresstown" />
                    <h:inputText id="addresstown" value="#{addressController.selected.addresstown}" title="#{bundle.CreateAddressTitle_addresstown}" />
                    
                    <h:outputLabel value="Numero de Telefono" for="addressphonenumber" />
                    <h:inputText id="addressphonenumber" value="#{addressController.selected.addressphonenumber}" title="#{bundle.CreateAddressTitle_addressphonenumber}" />
                    
                   
                    <h:outputLabel value="Ciudad" for="cityid" />
                    <h:selectOneMenu id="cityid" value="#{addressController.selected.cityid}" title="#{bundle.CreateAddressTitle_cityid}" required="true" requiredMessage="#{bundle.CreateAddressRequiredMessage_cityid}">
                        <f:selectItems value="#{cityController.itemsAvailableSelectOne}"/>
                    </h:selectOneMenu>
                    
                    <h:outputLabel value="" for="customerid" />
                    <h:inputHidden id="customerid" value="#{customerController.selected.customerid}" ></h:inputHidden>
                    
                    <h:outputLabel value="" for="customerid2" />
                    <h:inputHidden id="customerid2" value="#{addressController.selected.customerid}"></h:inputHidden>
                </h:panelGrid>
                <br />
                 <script>
                     document.getElementById('frm:customerid2').value = document.getElementById('frm:customerid').value;
                  </script>
                <h:commandLink action="#{addressController.create}" value="Crear" />
                <br />
                <br />
                <h:commandLink action="#{addressController.customer}" value="Volver al Cliente" immediate="true"  />
               
            </h:form>
        </ui:define>
    </ui:composition>

</html>
